package com.lrd.snapshotorder.protocol;

import lombok.Data;

/**
 * @Author:
 * @Description：统一返回对象
 */
@Data
public class ResultData<T> {
    private int code;
    private String message;
    private T data;
    private Long total;

    public ResultData() {
    }

    public ResultData(int code, String message, T data, Long total) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.total = total;
    }

    public static <T> ResultData<T> success(T t) {
        return new ResultData<T>(0, "", t, null);
    }

    public static <T> ResultData<T> error(String message) {
        return new ResultData<>(400, message, null, null);
    }
}
